<?php

namespace App\Http\Requests\Admin;

use App\Http\Requests\ApiRequest;
use Illuminate\Http\UploadedFile;

/**
 * @property int product_category_id
 * @property string name
 * @property string title
 * @property string sub_title
 * @property string description
 * @property UploadedFile thumb
 * @property string|null detail
 * @property int sort
 * @property string model_number
 * @property string specification
 * @property string keywords
 * @property  UploadedFile information
 */
class ProductionStoreRequest extends ApiRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'product_category_id' => 'required|numeric',
            'name'                => 'sometimes|string',
            'title'               => 'sometimes|required|string',
            'description'         => 'sometimes|required|string',
            'keywords'            => 'sometimes|required|string',
            'sub_title'           => 'sometimes|string',
            'model_number'        => 'required|string',
            'specification'       => 'sometimes|string',
            'thumb'               => 'required|file|max:5120',
            'detail'              => 'sometimes|string',
            'sort'                => 'sometimes|numeric',
            'information'         => 'sometimes|file',
        ];
    }

    /**
     * @return array
     */
    public function messages()
    {
        return [
            'product_category_id.*' => ':attribute必须是数字',
            'name.*'                => ':attribute必须是字符串',
            'title.*'               => ':attribute必须是字符串',
            'sub_title.*'           => ':attribute必须是字符串',
            'model_number.*'        => ':attribute必须是字符串',
            'specification.*'       => ':attribute必须是字符串',
            'thumb.*'               => ':attribute必须是小于5M的上传图片',
            'detail.*'              => ':attribute必须是字符串',
            'sort.*'                => ':attribute必须是数值',
            'information.*'         => ':attribute必须是文件',
        ];
    }

    /**
     * @return array
     */
//    public function attributes()
//    {
//        return [
//            'product_category_id' => '商品种类',
//            'name'                => '商品名称',
//            'title'               => '商品主标题',
//            'sub_title'           => '商品副标题',
//            'model_number'        => '商品的型号',
//            'specification'       => '商品规格',
//            'thumb'               => '商品缩略图',
//            'detail'              => '商品详情页',
//            'sort'                => '商品的排序',
//            'information'         => '商品资料信息',
//        ];
//    }
}
